home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
2410
/
2410.xpi
/
chrome
/
content
/
review.xml
< prev
Wrap
Extensible Markup Language
|
2010-01-28
|
11KB
|
276 lines
<?xml version="1.0"?>
<!DOCTYPE dialog SYSTEM "chrome://foxmarks/locale/foxmarks.dtd">
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="xmarks-review-stars">
<!-- content, property, method and event descriptions go here -->
<content>
<xul:vbox style="margin: 0 5px" >
<xul:image
src="chrome://foxmarks/skin/images/rating_0_stars.png"
width="75" height="15" style="cursor: pointer" />
<xul:spacer flex="1" />
</xul:vbox>
</content>
<handlers>
<handler event="mouseup" button="0">
<![CDATA[
this.rating = this.starIndex(event);
]]>
</handler>
<handler event="mouseover">
<![CDATA[
this.stars = this.starIndex(event);
]]>
</handler>
<handler event="mousemove">
<![CDATA[
this.stars = this.starIndex(event);
]]>
</handler>
<handler event="mouseout">
<![CDATA[
this.stars = this.rating;
]]>
</handler>
</handlers>
<implementation>
<constructor>
if (this.hasAttribute('rating')) {
this.rating = this.getAttribute('rating');
}
</constructor>
<method name="starIndex">
<parameter name="event" />
<body>
return Math.floor((event.clientX - this.boxObject.x - 5) /
15) + 1;
</body>
</method>
<property name="rating">
<getter>
return this.getAttribute('rating');
</getter>
<setter>
<![CDATA[
var v = Number(String(val), 10);
if (isNaN(v) || v < 0 || v > 5) {
return this.getAttribute('rating');
}
this.setAttribute('rating', ''+v);
this.stars = v;
return ''+v;
]]>
</setter>
</property>
<property name="stars">
<getter>
return this.getAttribute('stars');
</getter>
<setter>
<![CDATA[
var v = Number(val);
if (isNaN(v) || v < 0 || v > 5) {
return this.stars;
}
v = Math.round(v * 2) / 2.0;
if (this.stars != v) {
this.setAttribute('stars', ''+v);
var img = document.getAnonymousNodes(this)[0].
childNodes[0];
img.src = "chrome://foxmarks/skin/images/rating_" +
String(v) + "_stars.png";
}
return ''+v;
]]>
</setter>
</property>
</implementation>
</binding>
<binding id="xmarks-review-status">
<content>
<xul:hbox >
<xul:label style="margin: 2px 0 0 6px; padding: 0;" />
<xul:label class="text-link xmarks-review-link"
style="margin: 2px 0 0; padding: 0;
cursor: pointer !important;"
xbl:inherits="href" href="http://www.xmarks.com/" />
<xul:label style="margin: 2px 0 0; padding: 0;" />
<xul:spacer flex="100" />
</xul:hbox>
</content>
<implementation>
<constructor>
<![CDATA[
if (this.hasAttribute('iRated') &&
this.getAttribute('iRated') != 'true') {
this.iRated = false;
}
if (!this.hasAttribute('numRatings')) {
this.numRatings = 0;
}
this.updateText();
]]>
</constructor>
<method name="updateText">
<body>
<![CDATA[
var n = Xmarks.Bundle().GetStringFromName;
var f = Xmarks.Bundle().formatStringFromName;
var str = "";
if (this.numRatings > 0 && !this.iRated) {
str = f("reviews.otherrating", [this.numRatings], 1);
} else if (this.numRatings <= 1 && this.iRated) {
str = n("reviews.yourrating");
} else if (this.numRatings > 1 && this.iRated) {
str = f("reviews.bothrating", [this.numRatings], 1);
} else {
str = n("reviews.notyetrated");
}
var strs = str.split("|");
strs.push("");
strs.push("");
var box = document.getAnonymousNodes(this)[0];
box.childNodes[0].value = strs[0];
box.childNodes[1].value = strs[1];
box.childNodes[2].value = strs[2];
]]>
</body>
</method>
<property name="numRatings"
onget="return Number(this.getAttribute('numRatings'));">
<setter>
<![CDATA[
var v = Math.floor(Number(val));
if (isNaN(v) || v < 0) {
return this.numRatings;
}
this.setAttribute('numRatings', ''+v);
this.updateText();
return v;
]]>
</setter>
</property>
<property name="iRated"
onget="return this.hasAttribute('iRated');">
<setter>
<![CDATA[
var v = val && val != 'false';
if (v) {
this.setAttribute('iRated', 'true');
} else {
this.removeAttribute('iRated');
}
this.updateText();
return v;
]]>
</setter>
</property>
<property name="url">
<setter>
<![CDATA[
var url = val;
var label = document.getAnonymousNodes(this)[0].
childNodes[1];
url = url.replace(/^http:\/\//i, "");
var href = Xmarks.gSettings.httpProtocol +
Xmarks.gSettings.driftHost + "/site?url=" +
encodeURIComponent(url) + "&cid=xmfx.bd.review" +
"&product=xmarks&anchor=r";
label.href = href;
]]>
</setter>
</property>
</implementation>
</binding>
<binding id="xmarks-review">
<content>
<xul:vbox flex="1">
<xul:hbox>
<xul:xmarks-review-stars xbl:inherits="rating"
onclick="document.getBindingParent(this).clicked();"/>
<xul:xmarks-review-status
xbl:inherits="iRated,numRatings,href"/>
</xul:hbox>
<xul:textbox collapsed="true" multiline="true" rows="3"
xbl:inherits="value=reviewText"
class="menulist-editable-box"
emptytext= "&reviews.emptytext;"
oninput="document.getBindingParent(this).changed = true" />
</xul:vbox>
</content>
<implementation>
<constructor>
</constructor>
<field name="url" />
<field name="url_id" />
<property name="status">
<getter>
var ann = document.getAnonymousNodes(this)[0];
return ann.childNodes[0].childNodes[1];
</getter>
</property>
<property name="textbox">
<getter>
var ann = document.getAnonymousNodes(this)[0];
return ann.childNodes[1];
</getter>
</property>
<property name="stars">
<getter>
var ann = document.getAnonymousNodes(this)[0];
return ann.childNodes[0].childNodes[0];
</getter>
</property>
<property name="changed">
<getter>return this.hasAttribute("changed");</getter>
<setter>
if (val) {
this.setAttribute("changed", "true");
} else {
this.removeAttribute("changed");
}
</setter>
</property>
<method name="clicked">
<body>
this.status.iRated = true;
this.textbox.collapsed = false;
this.changed = true;
</body>
</method>
<method name="initialize">
<parameter name="url" />
<parameter name="url_id" />
<parameter name="count" />
<parameter name="average" />
<parameter name="rating" />
<parameter name="review" />
<body>
<![CDATA[
this.status.numRatings = count || 0;
this.status.iRated = rating != null;
this.status.url = url;
this.stars.rating = rating || average || 0;
this.textbox.value = review || "";
this.textbox.collapsed = !rating;
this.changed = false;
this.url = url;
this.url_id = url_id;
if (this.status.iRated && this.status.numRatings > 0) {
this.status.numRatings -= 1;
}
]]>
</body>
</method>
</implementation>
</binding>
</bindings>